package com.project.easy.common.util.util;

import com.project.easy.common.util.constants.CommonConstant;
import com.project.easy.common.util.date.DateTool;

import java.util.Date;
import java.util.Objects;

import static com.project.easy.common.util.constants.CommonConstant.YMDHMS;

/**
 * @author GreatorMan.cool
 * @copyright: Copyright (c) 2020
 * @company: 扬起科技有限公司
 * @description:
 * @date 2021/9/12 21:23
 */
public final class ConvertObjectToString {
    /**
     * 私有构造方法
     */
    private ConvertObjectToString() {
    }
    /**
     * @param param 数据类型
     * @return 返回数据字符串
     */
    public static  String convert(Object param) {
        if (Objects.isNull(param)) {
            return CommonConstant.EMPTY_STRING;
        }
        if (param instanceof  String) {
            return (String) param;
        } else if (param instanceof Date) {
          return DateTool.getStringDate((Date) param, YMDHMS);
        } else {
            return param.toString();
        }

    }
}
